
import os
import datetime
from flask import Flask

# 项目目录
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

AESKEY = "P-crEFkpluPPc67s"
MD5KEY = "M-crUmiPPac67sfe"

# 模版与静态目录
APP_URL = {
    "static_url_path": "/static/",
    "static_folder": os.path.join(BASE_DIR, 'static'),
    "template_folder": os.path.join(BASE_DIR, 'templates')
}

# 数据库

DATABASES = {
    "username": "root",
    "password": "a320326..",
    "host": "127.0.0.1",
    "port": "3306",
    "charset": "utf8",
    "bases": "pdd",
}

# 外部api配置
API_SET = {
    "ALIPAY": {
        "ONLINE":{
            "APP_ID":"2019120669677377",#支付宝应用id
            "APP_NOTIFY_URL":None,#支付宝默认回调地址 设置为None即可
            "APP_PRIVATE_KEY_PATH":os.path.join(BASE_DIR, 'app/libs/alipay/keys/app_private_key.pem'),#应用私钥文件路径
            "ALIPAY_PUBLIC_KEY_PATH":os.path.join(BASE_DIR, 'app/libs/alipay/keys/alipay_public_key.pem'),#应用私钥文件路径
            "SIGN_TYPE":"RSA2",#加密方式
            "RETURN_URL":"",#同步回调
            "NOTIFY_URL":"https://www.zhangguicha.com/zgc/pay/alinotify",#异步回调
            "TIME_EXPIRE":10,#过期分钟
        },
        "OFFLINE":{
            "APP_ID":"2016100100635779",#支付宝应用id
            "APP_NOTIFY_URL":None,#支付宝默认回调地址 设置为None即可
            "APP_PRIVATE_KEY_PATH":os.path.join(BASE_DIR, 'app/libs/alipay/debugkeys/app_private_key.pem'),#应用私钥文件路径
            "ALIPAY_PUBLIC_KEY_PATH":os.path.join(BASE_DIR, 'app/libs/alipay/debugkeys/alipay_public_key.pem'),#应用私钥文件路径
            "SIGN_TYPE":"RSA2",#加密方式
            "RETURN_URL":"",#同步回调
            "NOTIFY_URL":"http://253c93x519.wicp.vip/zgc/pay/alinotify",#异步回调
            "TIME_EXPIRE":10,#过期分钟
        },
        "DEBUG":True,

    },
    "QINIU": {
        "qiniu_url": "http://qfc9mkbf1.hn-bkt.clouddn.com/",
        "callback": "http://253c93x519.wicp.vip/",
        "bucket_name": "xtpdd",
        "access_key": "ing7eekTAf3-crEFkH7tFKy4b0m2yYT9IEpNXzS6",
        "secret_key": "4sHIH-w6SksS438URyJ3TjpOlD0JB4P3c8t2Bc3W",
    },
    "UPLOAD":{
        "access_key": "ing7eekTAf3-crEFkplogUjdu82yYT9IEpNXzS6",
    }
}

# cookies sessions 过期设置
TIMES = {
    "PERMANENT_SESSION_LIFETIME": datetime.timedelta(days=1),
    "PEMEMBER_COOKIE_DURATION": datetime.timedelta(days=1),
}


class config:
    SQLALCHEMY_DATABASE_URI = f'mysql+mysqlconnector://{DATABASES.get("username")}:{DATABASES.get("password")}@{DATABASES.get("host")}:{DATABASES.get("port")}/{DATABASES.get("bases")}?charset={DATABASES.get("charset")}'
    SQLALCHEMY_TRACK_MODIFICATIONS = True
    SESSION_PERMANENT = True
    PERMANENT_SESSION_LIFETIME = TIMES.get("PERMANENT_SESSION_LIFETIME")
    PEMEMBER_COOKIE_DURATION = TIMES.get("PEMEMBER_COOKIE_DURATION")
    SECRET_KEY = 'zhangguicha#$%^&*(*&^%$%^&*(*&^&*()_)(*SGHJK34H5JKP5OJO6J@#$%^&'
    JSONIFY_MIMETYPE = "application/json"
    DEBUG = True
